package GroupChats;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9999);
        //负责接收消息的线程
        new ThreadClient(socket).start();

        //主线程负责发送消息
        OutputStream os = socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(os);
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("请输入:");
            String str = scanner.nextLine();
            String sign = "exit";
            if (sign.equals(str)){
                System.out.println("退出成功!!!!");
                dos.close();
                socket.close();
                break;
            }
            dos.writeUTF(str);
            //刷新数据
            dos.flush();
        }
    }
}
